package com.yequan;

import java.math.BigDecimal;

/**
 * 测试
 *
 * @author yequan
 * @date 2020/12/08 15:30
 **/
public class ServeFeeUtil {

    /**
     * 获取同程服务费
     *
     * @param price 未上浮的价格， 分
     * @return 返回的是分
     */
    public static double getServeFee(float price) {
        double serveFeePercent = 0.05;
        return price * serveFeePercent;
    }

    /**
     * 获取同程的询价
     *
     * @param price 未上浮价格， 分
     * @return 返回的是分
     */
    public static double getTotalPrice(float price) {
        double serveFee = getServeFee(price);
        return price + serveFee;
    }

    /**
     * 获取未上浮价钱
     *
     * @param totalPrice
     * @return
     */
    public static double getOriginalPrice(float totalPrice) {
        double serveFeePercent = 0.05;
        return totalPrice / (1 + serveFeePercent);
    }

    public static void main(String[] args) {


//        double totalPrice = getTotalPrice((float) (225.4 * 100));
//        System.out.println(new BigDecimal(totalPrice).intValue());
//
//        double totalPrice2 = getTotalPrice((float) (72.7 * 100));
//        System.out.println(new BigDecimal(totalPrice2).intValue());
//
//        double totalPrice3 = getTotalPrice((float) (90.0 * 100));
//        System.out.println(new BigDecimal(totalPrice3).intValue());

//        float o1 = 72.3f;
//        double totalPrice1 = getTotalPrice(o1 * 100);
//        //返回给同程的
//        int tp1 = BigDecimal.valueOf(totalPrice1).setScale(0, BigDecimal.ROUND_HALF_UP).intValue();
//
//        //嘀嗒自己询价后上浮 5% 总价
//        int totalPriceC1 = BigDecimal.valueOf(ServeFeeUtil.getTotalPrice(o1 * 100)).intValue();
//
//        float clientPrice = tp1 / 100f ;
//        int ffff = BigDecimal.valueOf(clientPrice * 100).intValue();
//        System.out.println(totalPriceC1 + "   " + ffff);
//
//        System.out.println(BigDecimal.valueOf(getOriginalPrice(tp1)).setScale(0, BigDecimal.ROUND_HALF_UP).intValue());

//        double totalPrice = getTotalPrice(127.9f * 100);
//        System.out.println(totalPrice);
//        double cop = getOriginalPrice((float) totalPrice);
//        System.out.println(cop);
//        int price = new BigDecimal(totalPrice).setScale(0, BigDecimal.ROUND_HALF_UP).intValue();
//        int tongchengServeFee = BigDecimal.valueOf(ServeFeeUtil.getServeFee((float) (price / 1.05))).setScale(0, BigDecimal.ROUND_HALF_UP).intValue();
//        System.out.println(tongchengServeFee);


        BigDecimal driverReceivedPrice = BigDecimal.valueOf(90.90);
        BigDecimal subtract = BigDecimal.valueOf(getOriginalPrice(BigDecimal.valueOf(new BigDecimal("107.84").floatValue() * 100).setScale(0,BigDecimal.ROUND_HALF_UP).floatValue())).subtract(driverReceivedPrice);
        System.out.println(subtract.intValue());


        BigDecimal driverReceivedPrice1 = BigDecimal.valueOf(90.90);
        BigDecimal subtract1 = BigDecimal.valueOf(getOriginalPrice(BigDecimal.valueOf(new BigDecimal("102.70").floatValue() * 100).setScale(0,BigDecimal.ROUND_HALF_UP).floatValue())).subtract(driverReceivedPrice1);
        System.out.println(subtract1.intValue());

    }

}
